#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int FacSum(int m)
{
	int i = 0;
	int ret = 0;
	for (i = 1; i < m; i++)
	{
		if (m % i == 0)
		{
			ret += i;
		}
	}
	return ret;
}

int main()
{
	int n = 0;
	int sum = 0;

	scanf("%d", &n);

	sum = FacSum(n);

	printf("%d", sum);
	return 0;
}